package com.playball.lottery.util.province;

import android.app.Activity;
import android.content.Context;
import android.util.DisplayMetrics;

import com.nostra13.universalimageloader.core.DisplayImageOptions;

/**
 * Created by Administrator on 2017/3/14.
 */

public class GlobalUtils {

    // 屏幕分辨率
    private static float density;
    private static DisplayMetrics metrics;
    // 屏幕宽度
    private static int widthPixels;
    // 屏幕高度
    private static int heightPixels;
    // 小图图片显示设置
    private static DisplayImageOptions options;
    /**
     * 获取屏幕分辨率
     *
     * @param context
     * @return
     */
    public static float getDensity(Context context) {
        if (density == 0) {
            if (metrics == null) {
                getDisPlayMetrics(context);
            }
            density = metrics.density;
        }
        return density;
    }


    /**
     * 获取
     *
     * @param context
     * @return
     */
    public static DisplayMetrics getDisPlayMetrics(Context context) {
        if (metrics == null) {
            metrics = new DisplayMetrics();
            if (context instanceof Activity) {
                ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics);
            }
        }
        return metrics;
    }



    /**
     * 获取屏幕宽度
     *
     * @param context
     * @return
     */
    public static int getWidthPixels(Context context) {
        if (widthPixels == 0) {
            widthPixels = getDisPlayMetrics(context).widthPixels;
        }
        return widthPixels;
    }

    /**
     * 获取屏幕高度
     *
     * @param context
     * @return
     */
    public static int getHeightPixels(Context context) {
        if (heightPixels == 0) {
            heightPixels = getDisPlayMetrics(context).heightPixels;
        }
        return heightPixels;
    }

    /**
     * 获取图片下载的DisplayImageOptions对象
     *
     * @return
     */
    public static DisplayImageOptions getDisplayImageOptions() {
        return options;
    }


//    public static DisplayImageOptions getHeadDisplayImageOptions() {
//        return headOptions;
//    }
//
//    public static DisplayImageOptions getHeadCircleOptions() {
//        return headCircleOptions;
//    }

}
